package Commander;
import java.awt.Color;
import java.util.ArrayList;
/**
 * @author Charles Huang
 */
public class HeadQuarters
{
	private Color teamColor;
	private ArrayList<Unit> unitList;
	private ArrayList<Structure> structureList;
	private Commander Commander;
	private int PowerPoints;
	private int Funds;
	
	/**
	 * Constructor for Headquarters class
	 * sets default values, team color to red, team CO to Commander, and funds to 0
	 */
	public HeadQuarters()
	{
		teamColor = Color.red;
		unitList = new ArrayList<Unit>();
		structureList = new ArrayList<Structure>();
		Commander = new Commander();
		PowerPoints = 0;
		Funds = 0;
	}
	
	/**
	 * Constructor for Headquarters class
	 * @param teamColor - color of this side
	 * @param CO - Commanding officer of this side
	 * @param Funds - initial amount of funds
	 */
	public HeadQuarters(Color teamColor, Commander CO, int Funds)
	{
		this.teamColor = teamColor;
		unitList = new ArrayList<Unit>();
		structureList = new ArrayList<Structure>();
		this.Commander = CO;
		PowerPoints = 0;
		this.Funds = Funds;
	}
	
	/**
	 * @return color of the team
	 */
	public Color getTeamColor()
	{
		return teamColor;
	}
	
	/**
	 * @return this side's Commander
	 */
	public Commander getCommand()
	{
		return Commander;
	}
	
	/**
	 * @return Current amount of funds
	 */
	public int getFunds()
	{
		return Funds;
	}
	
	/**
	 * Precondition: player has enough funds to buy the unit
	 * subtracts funds when buying a unit
	 * @param price - cost of the unit
	 */
	public void spendFunds(int price)
	{
		Funds -= price;
	}
	
	/**
	 * adds funds at the beginning of each turn equal to the number of structures times 1000
	 */
	public void appropriateFunds()
	{
		Funds += structureList.size() * 1000;
	}
	
	/**
	 * adds Power Points to this side's point pool
	 * @param points - number of points to be added to the point pool
	 */
	public void addPoints(int points)
	{
		PowerPoints += points;
	}
	
	/**
	 * Precondition: player has enough PowerPoints to activate power
	 * activates the CO's special ability
	 */
	public void activatePower()
	{
		PowerPoints -= Commander.getPowerCost();
		Commander.activatePower();
	}
	
	/**
	 * turns off the CO's special ability
	 */
	public void deactivatePower()
	{
		Commander.deactivatePower();
	}
	
}
